package com.sg.java.apps;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class RunData2 {

    public static void main(String[] args) throws Exception {
        final Connection conn = DriverManager.getConnection("jdbc:postgresql://piscn.vicp.cc:55432/volt?", "volt", "volt2022");
        final File file = new File("C:\\Users\\HUAWEI\\Desktop\\volt");
        final File[] csvs = file.listFiles(pathname -> pathname.getName().endsWith(".csv"));
        if (csvs == null) {
            throw new RuntimeException("目录下无文件");
        }

        for (File csv : csvs) {
            final String s = csv.getName().replaceAll(".csv", "");
            final PreparedStatement ps = conn.prepareStatement("delete from dwd_cms." + s);
            ps.executeUpdate();
        }
        conn.close();
    }

}
